package com.muk.meis.model.service;

import java.util.List;

import javax.persistence.EntityTransaction;

import com.muk.meis.model.bean.Answer;

public class AnswerService extends BaseMEISService {

	public List<Answer> getList(int questionId) {
		return em.createQuery(
				"select e from Answer e where e.questionId = " + questionId,
				Answer.class).getResultList();
	}
	
	public int countAnswer(int questionId){
		return getList(questionId).size();
	}
	
	public void create(Answer answer){
		EntityTransaction t = em.getTransaction();
		t.begin();
		em.persist(answer);
		t.commit();
	}

}
